<template>
  <div>
    随机增加
    <Counter :number="number" />
  </div>
</template>
<script>
import Counter from './Counter';
export default {
  components:{
    Counter
  },
  data(){
    return{
      number: 0
    }
  },
  created(){
    this.$bus.on('add', num=>{
      this.number += num;
    })
  },
  beforeDestroy(){
    this.$bus.off('add', this.handleAddRandom);
  },
  methods: {
    handleAddRandom(num){
      this.number += num;
    }
  }
}
</script>
<style scoped>

</style>


